package com.bw.house.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.bw.house.entity.HouseModeEntity;
import com.bw.house.service.HouseModeService;
import com.bw.common.utils.PageUtils;
import com.bw.common.utils.R;



/**
 * 
 *
 * @author jwcz
 * @email 2898807664@qq.com
 * @date 2022-03-24 15:57:09
 */
@RestController
@RequestMapping("house/housemode")
public class HouseModeController {
    @Autowired
    private HouseModeService houseModeService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = houseModeService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{modeId}")
    public R info(@PathVariable("modeId") Integer modeId){
		HouseModeEntity houseMode = houseModeService.getById(modeId);

        return R.ok().put("houseMode", houseMode);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody HouseModeEntity houseMode){
		houseModeService.save(houseMode);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody HouseModeEntity houseMode){
		houseModeService.updateById(houseMode);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] modeIds){
		houseModeService.removeByIds(Arrays.asList(modeIds));

        return R.ok();
    }

}
